# gozerplugs/lart.py
#
#

""" luser adjustmenst reaction tool. """

__status__ = "seen"

## gozerbot imports 

from gozerbot.commands import cmnds
from gozerbot.persist.persistconfig import PersistConfig
from gozerbot.aliases import aliasset
from gozerbot.examples import examples
from gozerbot.plughelp import plughelp
from gozerbot.tests import tests

## basic imports

import random

## plughelp

plughelp.add('lart', 'do the lart')

## defines

cfg = PersistConfig()
cfg.define('lartlist', ['booo <who>', ])

## lart command

def handle_lart(bot, ievent):
    try: who = ievent.args[0]
    except IndexError: ievent.missing('<who>') ; return
    try: txt = random.choice(cfg.get('lartlist'))
    except IndexError: ievent.reply('lart list is empty .. use lart-add to add entries .. use "<who>" as a nick holder') ; return
    txt = txt.replace('<who>', who)
    bot.action(ievent.channel, txt)

cmnds.add('lart', handle_lart, 'USER')
examples.add('lart', 'echo a lart message', 'lart dunker')
aliasset('lart-add', 'lart-cfg lartlist add')
aliasset('lart-del', 'lart-cfg lartlist remove')
tests.add('lart', 'booo')

#### BHJTW 22-01-2012
